﻿using Uniforax.Core.Armors;
using Uniforax.Core.Common;
using Uniforax.Core.Common.Battle;
using Uniforax.Core.GameActions;
using Uniforax.Core.Interfaces;
using Uniforax.Core.Skills;
using Uniforax.Core.WorldFramework;

namespace Uniforax.Core.GameObjects
{
    ///<summary>游戏对象，所有游戏的对象，游戏内的生命周期都需要它。</summary>
    public abstract class BaseGameObject : IExecutableHost, ICloneable
    {
        public PosId PosId { get; set; }

        public int PlayerId { get; set; }

        public string ObjectId { get; set; }

        public int HP { get; set; }

        public int PowerRequired { get; set; } = 0;

        public int PowerProvide { get; set; } = 0;

        public bool HasChildren { get; set; } = false;

        public bool HasSerial { get; set; } = false;

        public bool HasShop { get; set; } = false;

        // 是否在创建
        public CreateStatus CreateStatus { get; set; }

        public BaseArmorManager ArmorManager { get; set; }

        public BaseMovement Movement { get; set; }

        public BaseSkillManager SkillManager { get; set; }

        public virtual IEnumerable<BaseGameObject> GetChildrenObjects()
        {
            return null;
        }

        ///<summary>获得商店信息。</summary>
        public BaseShop GetShopInfo()
        {
            return null;
        }

        ///<summary>获得生产线信息。</summary>
        public virtual IEnumerable<BaseSerial> GetSerials()
        {
            return null;
        }

        public BaseGameObject()
        {

        }

        public BaseGameObject(BaseGameObject other)
        {
            PosId = other.PosId;
            ObjectId = other.ObjectId;
        }

        public abstract object Clone();

        public void Execute(BaseGameAction action)
        {

        }

        public virtual void OnCreate(ActionContext context)
        {

        }

        public virtual void OnDestory(ActionContext context)
        {

        }

        // 进入这个格子了。
        public virtual void OnEnterGrid(ActionContext context, GameObjectEnterGridMovementContext moveContext)
        {

        }

        // 已经在此格子停下了。
        public virtual void OnPlacedGrid(ActionContext context, GameObjectPlaceGridMovementContext moveContext)
        {

        }

        // 离开了本格子。
        public virtual void OnLeaveGrid(ActionContext context, GameObjectLeaveGridMovementContext moveContext)
        {

        }

        public virtual void OnUnderAttack(ActionContext context, AttackContext attackContext)
        {

        }

        // 当获得的伤害是治愈系的。
        public virtual void OnHealed(ActionContext context)
        {

        }
    }
}
